<?php

abstract class Wpf_Controller {

	protected $ctx;

	public function __construct(Wpf_Ctx $context) {
		$this->ctx = $context;
	}

	public function doIndex() {

	}

	public function response($data=array(), $errorCode=0, $errorInfo="") {
		$output = array(
				'errorCode' => $code,
				'errorInfo' => $info,
				'data' => $data
		);
		echo json_encode($output);
	}

	final public function parseUrlParamByPattern($urlParamPattern) {
		$m = $this->ctx->Wpf_Router->parseUrlParamByPattern($urlParamPattern);
		$_REQUEST = array_merge($_REQUEST, $m);
	}

	public function getParam($key) {
		return isset($_REQUEST[$key]) ? $_REQUEST[$key] : null;
	}
}